package com.woniu.daiquhua.config;


import com.woniu.daiquhua.intecepters.PermissionIntercepter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //实现拦截器配置
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new PermissionIntercepter())
                .addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/asserts/**")
                .excludePathPatterns("/login.html")
                .excludePathPatterns("/index.html")
                .excludePathPatterns("/register1.html")
                .excludePathPatterns("/register.html")
                .excludePathPatterns("/user/findUAccount")
                .excludePathPatterns("/user/findMobile")
                .excludePathPatterns("/defaultKaptcha")
                .excludePathPatterns("/code")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/findOne")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/phone/code")
                .excludePathPatterns("/phone/verifyCode");

    }

    //注册路由自动映射
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/login.html").setViewName("login");//找视图解析器
        registry.addViewController("/register.html").setViewName("register");
        registry.addViewController("/register1.html").setViewName("register1");

        registry.addViewController("/list.html").setViewName("list");
        registry.addViewController("/infor.html").setViewName("infor");
        registry.addViewController("/loan.html").setViewName("loan");
        registry.addViewController("/help.html").setViewName("help");
        registry.addViewController("/personalIndex.html").setViewName("personalIndex");
        registry.addViewController("/companyInfo.html").setViewName("companyInfo");
        registry.addViewController("/personal-AccountSettings.html").setViewName("personal-AccountSettings");
        registry.addViewController("/personal-CollectionPlan.html").setViewName("personal-CollectionPlan");
        registry.addViewController("/personal-ExchangeHistory.html").setViewName("personal-ExchangeHistory");
        registry.addViewController("/personal-FundRecord.html").setViewName("personal-FundRecord");
        registry.addViewController("/personal-InvestmentRecord.html").setViewName("personal-InvestmentRecord");
        registry.addViewController("/personal-OpenThird.html").setViewName("personal-OpenThird");
        registry.addViewController("/personal-Recharge.html").setViewName("personal-Recharge");
        registry.addViewController("/personal-RedEnvelope.html").setViewName("personal-RedEnvelope");
        registry.addViewController("/personal-SystemMsg.html").setViewName("personal-SystemMsg");
        registry.addViewController("/personal-Withdrawal.html").setViewName("personal-Withdrawal");
        registry.addViewController("/tariffDescription.html").setViewName("tariffDescription");
        registry.addViewController("/teamStyle.html").setViewName("teamStyle");
        registry.addViewController("/websiteAnnouncement.html").setViewName("websiteAnnouncement");
        registry.addViewController("/companyAnnouncementDetails.html").setViewName("companyAnnouncementDetails");
        registry.addViewController("/contact.html").setViewName("contact");
        registry.addViewController("/cooperativePartner.html").setViewName("cooperativePartner");
        registry.addViewController("/legalDeclaration.html").setViewName("legalDeclaration");
        registry.addViewController("/legalPolicy.html").setViewName("legalPolicy");
        registry.addViewController("/managementTeam.html").setViewName("managementTeam");
        registry.addViewController("/mediaCoverage.html").setViewName("mediaCoverage");
        registry.addViewController("/recruit.html").setViewName("recruit");

    }
}
